package com.itheima.config;

import com.itheima.pojo.Apple;
import com.itheima.pojo.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @author lcz
 * @date 2020/4/22.
 * @Description
 */
@Configuration    //声明是一个配置类
public class UserConfig {

    @Bean
    public Apple apple(){
        return new Apple();
    }

    @Bean
   // @Conditional(ClassCondition.class)
    @ConditionalOnMissingBean(Apple.class)
    //@ConditionalOnBean
    public User user(){
        User user = new User();
        user.setName("张三");
        user.setAge(20 );
        return user;
    }
}
